package com.springboot.demo.sort;

import java.util.Arrays;

import org.junit.Test;

/**
 * 排序测试
 *
 * @author supu
 * @date 2019-12-12 10:39
 **/
public class SortDemo {
    private int[] a = {32,43,23,13,5,40};

    @Test
    public void insertSortTest(){
        System.out.println("插入排序前：" + printArray());
        InsertSort.insertSort1(a);
        System.out.println("插入排序后：" + printArray());
    }

    @Test
    public void hillSortTest(){
        System.out.println("希尔排序前：" + printArray());
        HillSort.hillSort1(a);
        System.out.println("希尔排序后：" + printArray());
    }

    @Test
    public void selectSortTest(){
        System.out.println("选择排序前：" + printArray());
        SelectSort.selectSort1(a);
        System.out.println("选择排序后：" + printArray());
    }

    @Test
    public void bubbleSortTest(){
        System.out.println("冒泡排序前：" + printArray());
        BubbleSort.bubbleSort1(a);
        System.out.println("冒泡排序后：" + printArray());
    }

    @Test
    public void quickSortTest(){
        System.out.println("快速排序前：" + printArray());
        QuickSort.quickSort1(a, 0, a.length-1);
        System.out.println("快速排序后：" + printArray());
    }

    @Test
    public void mergeSortTest(){
        System.out.println("归并排序前：" + printArray());
        MergeSort.mergeSort(a, 0, a.length-1);
        System.out.println("归并排序后：" + printArray());
    }

    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);
        System.out.println((Integer.MAX_VALUE + 10) /2);
        System.out.println((Integer.MAX_VALUE + 10) >>> 1);
        System.out.println(10 + (Integer.MAX_VALUE - 10) /2);
    }

    private String printArray(){
        return Arrays.toString(a);
    }
}
